﻿using System.Collections.Generic;

namespace MakeTheStringGreat
{
    public class Solution
    {
        public string MakeGood(string s)
        {
            var list = new List<char>();

            foreach (var c in s)
            {
                var peek = list.Count == 0 ? '0' : list[list.Count - 1];
                if (peek != c && char.ToLower(peek) == char.ToLower(c))
                {
                    list.RemoveAt(list.Count - 1);
                }
                else
                {
                    list.Add(c);
                }
            }

            return string.Join("", list);
        }
    }
}
